package com.ssyt.blog.core.sys.entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.DynamicUpdate;

import com.ssyt.blog.core.common.util.DateUtil;

@Entity
@Table(name = "article", catalog = "blog")
@DynamicUpdate
public class Article implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = IDENTITY)
	private Integer id;
	private String title;
	private String content;
	@Column(name = "create_time", nullable = false, length = 19)
	private Date createTime;
	@Column(name = "read_times", nullable = false)
	private Integer readTimes;
	@Column(name = "category_id", nullable = false)
	private Integer categoryId;
	@Column(name = "user_id", nullable = false)
	private Integer userId;

	@Transient
	private String userName;
	@Transient
	private String photo;
	@Transient
	private String categoryName;
	@Transient
	private String blogName;
	@Transient
	private String description;
	@Transient
	private String bgImage;

	// Constructors

	/** default constructor */
	public Article() {
	}

	public Article(Integer id, String title, String content, Date createTime,
			Integer readTimes, Integer userId, String categoryName) {
		super();
		this.id = id;
		this.title = title;
		this.content = content;
		this.createTime = createTime;
		this.readTimes = readTimes;
		this.userId = userId;
		this.categoryName = categoryName;
	}

	public Article(Integer id, String title, String content, Date createTime,
			Integer readTimes, String userName, String photo, Integer userId,
			String categoryName, String blogName, String description,
			String bgImage) {
		super();
		this.id = id;
		this.title = title;
		this.content = content;
		this.createTime = createTime;
		this.readTimes = readTimes;
		this.userName = userName;
		this.photo = photo;
		this.userId = userId;
		this.categoryName = categoryName;
		this.blogName = blogName;
		this.description = description;
		this.bgImage = bgImage;
	}

	public String getBlogName() {
		return blogName;
	}

	public void setBlogName(String blogName) {
		this.blogName = blogName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getBgImage() {
		return bgImage;
	}

	public void setBgImage(String bgImage) {
		this.bgImage = bgImage;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPhoto() {
		return photo;
	}

	public void setPhoto(String photo) {
		this.photo = photo;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	// Property accessors
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getCreateTime() {
		return DateUtil.format(this.createTime, "yyyy-MM-dd");
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Integer getReadTimes() {
		return this.readTimes;
	}

	public void setReadTimes(Integer readTimes) {
		this.readTimes = readTimes;
	}

	public Integer getCategoryId() {
		return this.categoryId;
	}

	public void setCategoryId(Integer categoryId) {
		this.categoryId = categoryId;
	}

	public Integer getUserId() {
		return this.userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	@Override
	public String toString() {
		return "Article [id=" + id + ", title=" + title + ", content="
				+ content + ", createTime=" + createTime + ", readTimes="
				+ readTimes + ", categoryId=" + categoryId + ", userId="
				+ userId + ", userName=" + userName + ", photo=" + photo
				+ ", categoryName=" + categoryName + ", blogName=" + blogName
				+ ", description=" + description + ", bgImage=" + bgImage + "]";
	}

}